import { type } from "../../utils/common";

export default items =>
  items
    .map(q => {
      const component = "Label";
      const props = {
        value: q.value,
        options:
          type(q.optionText) === "string"
            ? JSON.parse(q.optionText || "{}")
            : undefined,
        fieldType: q.fieldType,
        id: q.fieldCode,
        editable: false,
        label: q.fieldName,
        visible: true,
        required: q.required
      };
      if (component) {
        return {
          component,
          props
        };
      }
    })
    .filter(q => q); // 过滤掉空的（也就是说我目前不支持的
